<?php
	defined('DB_PATH') || define('DB_PATH','/data/cloud/logs/13duser.sqlite2');//dirname(dirname(dirname(dirname(__FILE__)))).'/static/13duser.sqlite2'
	class DB_Sqlite2{
		private static $_instance;
		protected $_db; 
		public $db_path;
		private function __construct(){
			$this->db_path = DB_PATH;
			$this->_db = sqlite_open($this->db_path);
		}
		function __destruct(){
			sqlite_close($this->_db);
			unset($this->_db);
		}
		private function __clone(){}
		public function initialize(){
			if(empty(self::$_instance)){    
				self::$_instance = new self();    
			}  
			return self::$_instance;    
		}
		public function query($sql){ //直接运行SQL，可用于更新、删除数据
			$ret = @sqlite_query($this->_db,$sql);
			return $ret;
		}
		public function fetch_array($sql){ //取得下一行并返回一个数组
			return sqlite_fetch_array($this->query($sql));
		}
		public function array_query($sql){ //取得数据集并返回到一个数组
			return sqlite_array_query($this->_db,$sql);
		}
		public function getLastError(){
			return @sqlite_last_error($this->_db);
		}
	}